package com.yj.cmp.sdk.fusioncompute.util;

import com.yj.cmp.sdk.fusioncompute.common.utils.ApiInitUtil;
import com.yj.cmp.sdk.fusioncompute.identity.FcIdentityApi;
import com.yj.cmp.sdk.fusioncompute.identity.dto.LoginDto;
import com.yj.cmp.sdk.fusioncompute.identity.vo.LoginVo;
import retrofit2.Response;

import java.util.HashMap;
import java.util.Map;

/**
 * 初始化工具
 */
public class InitUtil {


    public static Map<String, Object> getToken() {
        LoginDto loginDto = new LoginDto();
        loginDto.setUsername("yunju_view");
        loginDto.setPassword("f66535238ef9fb93e41d457913ff64e5831e922c641351c46865bbe8311d1096");
        String url = "https://192.168.56.165:7443/";
        ApiInitUtil apiInitUtil = new ApiInitUtil(url);
        FcIdentityApi fcIdentityApi = apiInitUtil.getFcIdentityApi();
        Response<LoginVo> token = null;
        try {
            token = fcIdentityApi.token(loginDto);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Map<String, Object> headerMap = new HashMap<>(8);
        headerMap.put("Content-Type", "application/json; charset=UTF-8");
        headerMap.put("Accept", "application/json;version=6.5; charset=UTF-8");
        headerMap.put("Accept-Language", "zh_CN");
        headerMap.put("X-Auth-Token", token.headers().get("X-Auth-Token"));
        return headerMap;
    }

    public static String address() {
        return "https://192.168.56.165:7443/service/sites/4ADB0874/";
    }

}
